#ifndef __COMM_HPP__
#define __COMM_HPP__

#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>

using namespace std;
#define size 4096
const string pathname="/home/slm";
const int proj_id = 0x6668;


key_t Getkey()
{
    key_t key = ftok(pathname.c_str(),proj_id);
    if(key < 0)
    {
        return 1;
    }

    return key;
}

int Getmem(int flag)
{
    key_t key = Getkey();
    int shmid = shmget(key,size,flag);
    if(shmid < 0)
    {
        return 2;
    }
    return shmid;
}

int CreateShm()
{
    return Getmem(IPC_CREAT|IPC_EXCL|0666);
}

int GetShm()
{
    return Getmem(IPC_CREAT);
}


#endif